package com.klz.iblog.service.serviceImpl;

import com.klz.iblog.dao.BlogMapper;
import com.klz.iblog.pojo.Blog;
import com.klz.iblog.service.BlogService;
import com.klz.iblog.vo.ArchiveInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogServiceImpl implements BlogService {

    @Autowired(required = false)
    private BlogMapper blogMapper;

    /**
     * 查看所有博客的点赞量
     * @return
     */
    @Override
    public Integer selectAllLikeNumCounts() {
        return blogMapper.selectAllLikeNumCounts();
    }

    /**
     * 查询所有博客的浏览量
     * @return
     */
    @Override
    public Integer selectAllBrowseNumCounts() {
        return blogMapper.selectAllBrowseNumCounts();
    }

    /**
     * 查询所有博客总数
     * @return
     */
    @Override
    public Integer selectAllBlogCount() {
        return blogMapper.selectAllBlogCount();
    }

    /**
     * 分页查询博客信息
     * @return
     */
    @Override
    public List<Blog> selectPageBlogInfo() {
        return blogMapper.selectPageBlogInfo();
    }

    /**
     * 按浏览量分页查询博客信息
     * @return
     */
    @Override
    public List<Blog> selectPageBlogInfoByBrowseNum() {
        return blogMapper.selectPageBlogInfoByBrowseNum();
    }

    /**
     * 查询热门博客推荐信息
     * @param hotBlogLimitNum
     * @return
     */
    @Override
    public List<Blog> selectHotBlogs(Integer hotBlogLimitNum) {
        return blogMapper.selectHotBlogs(hotBlogLimitNum);
    }

    /**
     * 查询最新博客的推荐信息
     * @param newBlogLimitNum
     * @return
     */
    @Override
    public List<Blog> selectNewBlogs(Integer newBlogLimitNum) {
        return blogMapper.selectNewBlogs(newBlogLimitNum);
    }

    /**
     * 根据博客id,查询博客的详细信息
     * @param blogId
     * @return
     */
    @Override
    public Blog selectBlogDetailInfo(Integer blogId) {
        return blogMapper.selectBlogDetailInfo(blogId);
    }

    /**
     * 查询归档信息
     * @return
     */
    @Override
    public List<ArchiveInfo> selectArchivesInfo() {
        return blogMapper.selectArchivesInfo();
    }


    /**
     *  按年月分页归档查询博客列表信息
     * @param date
     * @return
     */
    @Override
    public List<Blog> selectBlogInfoByArchive(String date) {
        return blogMapper.selectBlogInfoByArchive(date);
    }

    /**
     * 查询该博客详情和所有评论
     * @param blogId
     * @return
     */
    @Override
    public List<Blog> selectBlogAllCommentsInfo(Integer blogId) {
        return blogMapper.selectBlogAllCommentsInfo(blogId);
    }

}
